'''
Created on Oct 21, 2009

@author: kage
'''

from PyBatch.handlers import base

class Muxer(base.MuxBase):
    def start(self, args=None):
        q='"'
        self.__inputVideoPath = args['inputVideoPath'].replace('\\','/')
        self.__inputAudioPath = args['inputAudioPath'].replace('\\','/')
        self.__inputAudioLang = args['inputAudioLang']
        self.__outputPath = args['outputPath']
        self.__change_fps = args['change_fps']
        self.__fps = str(args['fps'])
        self.__title = args['title']
    
        #muxing command and arguments
        self.__command = q + self.mkvMergePath + q + " -o " + q + self.__outputPath + q
        self.__command += ' "--priority" "' + self.priority + '" "--default-track" "1:yes" "--forced-track" "1:no"'
        if self.__change_fps:
            self.__command += ' "--default-duration" 1:' + q + self.__fps + q + ""
        self.__command += ' "-d" "1" "-A" "-S" "-T" "--no-global-tags" ' + q + self.__inputVideoPath + q
        
        #TODO implement optional args
        self.__command += ' "--language" "1:' + self.__inputAudioLang + '" "--default-track" "1:yes" "--forced-track" "1:no" ' #"--aac-is-sbr" "0:1" optional before language option
        self.__command += '"-a" "1" "-D" "-S" "-T" "--no-global-tags" ' + q + self.__inputAudioPath + q + '  "--track-order" "0:1,1:1" "--title" "' + self.__title + '"' #may need to change 1 to 0 for aac    
        
        print self.__command
        self.setCommandLine(self.__command)
        self.muxOperation()
